package com.lzh.others.basejava.Anotation_20;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Classname UseCaseTracker
 * @Description ctrl+alt+o 快速清除没用的import
 * @Date 2021/11/1 10:54
 * @Created by liuzihao
 */
public class UseCaseTracker {
    public static void trackUseCases(List<Integer> useCases, Class<?> cl) {
        for (Method m : cl.getDeclaredMethods()) {
            UseCase annotation = m.getAnnotation(UseCase.class);
            if (annotation != null) {
                System.out.println("Found Use Case:" + annotation.id() +
                        " " + annotation.description());
                useCases.remove(new Integer(annotation.id()));
            }
        }
        for (Integer useCase : useCases) {
            System.out.println("Warning : Missing use case-" + useCase);
        }
    }

    public static void main(String[] args) {
        List<Integer> useCases = new ArrayList<>();
        Collections.addAll(useCases,47,48,49,50);
        trackUseCases(useCases,PasswordUtils.class);
    }
}
